import java.util.LinkedList;
import java.util.Stack;

public class Test {
   //底层用用双向链表实现了栈
   public static void main(String[] args) {
      LinkedList<Integer> stack=new LinkedList<>();
      stack.push(1);
      stack.push(2);
      System.out.println(stack.pop());//2
   }


   //测试库里的栈
   public static void main2(String[] args) {
      Stack<Integer> stack=new Stack<>();

      stack.push(12);
      stack.push(23);
      stack.push(34);
      stack.push(45);

      int val=stack.pop();
      System.out.println(val);//45
      val=stack.pop();
      System.out.println(val);//34

      val=stack.peek();
      System.out.println(val);//23

      boolean empty= stack.isEmpty();
      System.out.println(empty);//flase
   }


   //测试自己的myStack
   public static void main1(String[] args) {
      MyStack myStack = new MyStack();
      myStack.push(1);
      myStack.push(2);
      myStack.push(3);
      myStack.push(7);//1 2 3 7
//   for(int x:myStack.elem){
//      System.out.println(x+" ");
//   }
      int val=myStack.pop();
      System.out.println(val);//7
      val=myStack.pop();
      System.out.println(val);//3

      int val1=myStack.peek();
      System.out.println(val1);//2
   }
}

